import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by lrs on 2018/2/24.
 */
public class StringUtil {

    /**
     * 根据正则截取匹配到的字符串
     * @param str 原始字符串
     * @param regex 正则表达式
     * @return 返回的匹配到的list
     */
    public static List<String> subString(String str, String regex) {
        List<String> list = new ArrayList<String>();
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(str);
        while (matcher.find()) {
            list.add(matcher.group());
        }
        return list;
    }

}
